package com.ruoyi.neusoft.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.neusoft.domain.StudentInfoT;
import com.ruoyi.neusoft.service.IStudentInfoTService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生信息Controller
 * 
 * @author ruoyi
 * @date 2023-12-19
 */
@Controller
@RequestMapping("/neusoft/StuService")
public class StudentInfoTController extends BaseController
{
    private String prefix = "neusoft/StuService";

    @Autowired
    private IStudentInfoTService studentInfoTService;

    @RequiresPermissions("neusoft:StuService:view")
    @GetMapping()
    public String StuService()
    {
        return prefix + "/StuService";
    }

    /**
     * 查询学生信息列表
     */
    @RequiresPermissions("neusoft:StuService:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(StudentInfoT studentInfoT)
    {
        startPage();
        List<StudentInfoT> list = studentInfoTService.selectStudentInfoTList(studentInfoT);
        return getDataTable(list);
    }

    /**
     * 导出学生信息列表
     */
    @RequiresPermissions("neusoft:StuService:export")
    @Log(title = "学生信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(StudentInfoT studentInfoT)
    {
        List<StudentInfoT> list = studentInfoTService.selectStudentInfoTList(studentInfoT);
        ExcelUtil<StudentInfoT> util = new ExcelUtil<StudentInfoT>(StudentInfoT.class);
        return util.exportExcel(list, "学生信息数据");
    }

    /**
     * 新增学生信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存学生信息
     */
    @RequiresPermissions("neusoft:StuService:add")
    @Log(title = "学生信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(StudentInfoT studentInfoT)
    {
        return toAjax(studentInfoTService.insertStudentInfoT(studentInfoT));
    }

    /**
     * 修改学生信息
     */
    @RequiresPermissions("neusoft:StuService:edit")
    @GetMapping("/edit/{userId}")
    public String edit(@PathVariable("userId") Long userId, ModelMap mmap)
    {
        StudentInfoT studentInfoT = studentInfoTService.selectStudentInfoTByUserId(userId);
        mmap.put("studentInfoT", studentInfoT);
        return prefix + "/edit";
    }

    /**
     * 修改保存学生信息
     */
    @RequiresPermissions("neusoft:StuService:edit")
    @Log(title = "学生信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(StudentInfoT studentInfoT)
    {
        return toAjax(studentInfoTService.updateStudentInfoT(studentInfoT));
    }

    /**
     * 删除学生信息
     */
    @RequiresPermissions("neusoft:StuService:remove")
    @Log(title = "学生信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(studentInfoTService.deleteStudentInfoTByUserIds(ids));
    }
}
